package com.itheima.tanhua.web;


import com.itheima.tanhua.vo.AdminUserInfoVo;
import com.itheima.tanhua.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Map;


@RestController
@RequestMapping("/system/users")
public class SystemController {

    @Autowired
    private AdminService adminService;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    //用户登录验证码图片
    @GetMapping("/verification")
    public ResponseEntity verification(@RequestParam("uuid") String uuid) throws IOException {
        adminService.verification(uuid);
        return ResponseEntity.ok(null);
    }
    //登录后台系统
    @PostMapping("/login")
    public ResponseEntity login(@RequestBody Map<String, String> map) {
        return  adminService.login(map);

    }
    //获取用户的详细信息
    @PostMapping("/profile")
    public ResponseEntity userInfo(){
        AdminUserInfoVo adminUserInfoVo=adminService.adminUserInfo();
        return ResponseEntity.ok(adminUserInfoVo);
    }
    //登录后台系统
    @PostMapping("/logout")
    public ResponseEntity logout() {
        return adminService.logout();
    }

}

